#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#define random(x)(rand()%x)

int main()
{
	int i,j;
	int x = 6;
	int y = 6;
	int ny = 6;
	char input;
	
	int isFired = 0;
	int isKilled = 0;
	int Score = 0;
	int Round = 0;
	
	while(1)
	{
		int k = random(10);
		system("cls");
			printf("得分:%d\n",Score);
		
		if(isKilled == 0)
		{
			for (i=0;i<ny;i++)
				printf(" ");
			printf("+\n");
		}
		else
		{
			printf("\n");
			if (Round%5==0)
				ny = ny - k;
			else
				ny = ny + k;
			isKilled = 0;
		}
		if(isFired == 0)
		{
			for (i=0;i<x;i++)
				printf("\n");
		}
		else
		{
			for (i=0;i<x;i++)
			{
				for(j=0;j<y;j++)
					printf(" ");
				printf("  |\n");
			}
			if(y+2==ny)
			{
				isKilled = 1;
				Score++;
			}
			isFired = 0;
		}
		Round++;
		for(j=0;j<y;j++)
			printf(" ");
		printf("  *\n");
		for(j=0;j<y;j++)
			printf(" ");
		printf("*****\n");
		for(j=0;j<y;j++)
			printf(" ");
		printf(" * *");
		input = getch();
		if(input=='s')
			x++;
		if(input=='w')
			x--;
		if(input=='a')
			y--;
		if(input=='d')
			y++;
		if(input==' ')
			isFired = 1;
	}			
	return 0;
}
